/**
 * JAVACC DEMO 1.0
 */
package com.apache.passport.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.cache.util.Validator;
import com.apache.database.db.IDao;
import com.apache.database.model.MethodParam;
import com.apache.passport.entity.UctUser;

/**
 * description:  验证密码是否正确
 *
 * @author Hou Dayu 创建时间：2016-1-4
 */
public class CheckPassPlugin extends SuperPluginConnector {

    /*protected IDao uctUserDao;

    public void setUctUserDao(IDao uctUserDao) {
        this.uctUserDao = uctUserDao;
    }*/

    /**
     * TODO 简单描述该方法的实现功能（可选）.
     *
     * @see com.apache.api.manager.PluginConnector#execute(com.apache.api.vo.ParamsVo)
     */
    @Override
    public Object execute(ParamsVo vo) throws Exception {
        ResultEntity result = new ResultEntity();
        result.setResult("true");
        result.setEntity("F");
        result.setMessage("密码不正确");
        String userPass = (String) vo.getParams("userPass");
        String userEname = ((UctUser)vo.getObj()).getUserEname();
        UctUser obj = (UctUser) getInfoByEname(userEname);
        if (!Validator.isEmpty(obj) && userPass.equals(obj.getUserPass())) {
            result.setEntity("T");
            result.setMessage("密码正确");
        }
        return result;
    }

}
